function setCookie(name: string, value: string | number, n: number): void {
  const oDate = new Date();
  oDate.setDate(oDate.getDate() + n);
  document.cookie = name + "=" + value + ";expires=" + oDate;
}

function getCookie(name: string): string | undefined {
  const str = document.cookie;
  const arr = str.split("; ");
  for (let i = 0; i < arr.length; i++) {
    //console.log(arr[i]);
    const newArr = arr[i].split("=");
    if (newArr[0] == name) {
      return newArr[1];
    }
  }
}

function removeCookie(name: string): void {
  setCookie(name, 1, -1);
}

export { getCookie, setCookie, removeCookie };
